/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import Common.Constant;
import Helper.BillsHepler;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author KIENLT
 */
public class BillsDetailModel extends AbstractTableModel {

    ArrayList<BillsHepler> BillsList;
    private final String colunmsName[] = {Constant.getBundle().getString("Id"), Constant.getBundle().getString("Cname"), Constant.getBundle().getString("Discount"), Constant.getBundle().getString("Vat"), Constant.getBundle().getString("Payment")};
    private final Class columnsClass[] = {String.class, String.class, String.class, String.class, String.class};

    public BillsDetailModel(ArrayList<BillsHepler> BillsList) {
        this.BillsList = BillsList;
    }

    @Override
    public int getRowCount() {
        return BillsList.toArray().length;
    }

    @Override
    public int getColumnCount() {
        return colunmsName.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return BillsList.get(rowIndex).getId();
            case 1:
                return BillsList.get(rowIndex).getCusName();
            case 2:
                return BillsList.get(rowIndex).getDiscount();
            case 3:
                return BillsList.get(rowIndex).getVAT();
            case 4:
                return BillsList.get(rowIndex).getPayment();
            default:
                return null;
        }
    }

    @Override
    public String getColumnName(int icol) {
        return colunmsName[icol];
    }

    @Override
    public Class getColumnClass(int icol) {
        return columnsClass[icol];
    }
}
